$.bsgrid.forcePushPropertyInObject(
		$.fn.bsgrid.defaults.extend.renderPerRowMethods,
		'extend_render_per_row', function(record, rowIndex, trObj, options) {
			if (record != undefined && record != '') {
				trObj.attr('id', record.id);
			}
		});
$(function() {
	var token=localStorage.getItem("token");
	$(".z_addpost").click(Add);
	$(".z_delpost").click(getCheckedIds);
	gridObj = $.fn.bsgrid.init('g_tabYeh', {
		ajaxType : 'get',
		url : server_url+'rest/postList.do?ran=' + Math.random() + '&token=' + token,
		autoLoad : true,
		pageSizeSelect : true,
		stripeRows : true,
		pageSize : 10,
		displayBlankRows : false,
		isProcessLockScreen : true,
		rowSelectedColor : false
	});
});
function operate(record, rowIndex, colIndex, options) {
	return '<a href="javascript:Edit(\''+ gridObj.getRecordIndexValue(record, 'id')+ '\');">编辑</a>'
		+'<a href="javascript:Arrange(\''+ gridObj.getRecordIndexValue(record, 'id')+ '\');">分配菜单</a>'
		+'<a href="javascript:Copy(\''+ gridObj.getRecordIndexValue(record, 'id')+ '\');">复制岗位</a>'
		+'<a href="javascript:Review(\''+ gridObj.getRecordIndexValue(record, 'id') + '\');">查看</a>';
}
// 获取checkbox选中
function getCheckedIds() {
	var token=localStorage.getItem("token");
	var username=localStorage.getItem("username");
	var ids = gridObj.getCheckedValues('id').toString();
	if (ids == "") {
		easyDialog.open({
			container:{
				header:'温馨提示',
				content:"请选择要操作的记录！"
			},
			autoClose : 2000
		});

	} else {
		easyDialog.open({
			  container : {
				header:'温馨提示',
			    content : '您确定要删除吗？',
			    yesFn : function(){
			    	$.ajax({
						url : server_url+'rest/deletePost.do',
						type : 'post',
						dataType : 'json',
						data : {
							ids : ids,
							modifyUser : username,
							token:token
						},
						success : function(data) {
							if (data.retCode = "0000") {
								var url='postList.do?ran='+Math.random();
								tl_config.loadToWorkArea(url);
							} else 
								easyDialog.open({
									container:{
										header:'温馨提示',
										content:data.retMsg
									},
									autoClose : 2000
								});

						}
					});
			    },
			    noFn : true
			  }
			});

	}
}
// 数据表格参数查询
function doSearch() {
	searchParames = $('#myform').serialize();
	if ($('#post_name').val() == '') {
		gridObj.search('');
	} else {
		gridObj.search(searchParames);
	}
	console.log(searchParames);
}
// 编辑
function Edit(id) {
	var url='postEdit.do?id='+id+'&ran='+Math.random();
	tl_config.loadToWorkArea(url);
}
// 分配菜单
function Arrange(id) {
	var url='assignMenu.do?id='+id+'&ran='+Math.random();
	tl_config.loadToWorkArea(url);
}
// 复制岗位
function Copy(id) {
	var url='copyPost.do?id='+id+'&ran='+Math.random();
	tl_config.loadToWorkArea(url);
}
// 查看
function Review(id) {
	var url='checkAuthority.do?id='+id+'&ran='+Math.random();
	tl_config.loadToWorkArea(url);
}
//添加
function Add() {
	var url='postAdd.do?ran='+Math.random();
	tl_config.loadToWorkArea(url);
}